<?php
	if(!isset($_REQUEST['ajax'])){ $_REQUEST['ajax'] = "";}
	if($_REQUEST['ajax']!=true) include 'header.tpl.php';
?>
	<div class="row">
		<div class="col-lg-12">
			<ul class="shortcut-buttons-set">
				<li>
					<a class="shortcut-button" data-toggle="modal" href='#type_create' ><span>
					<img src="resources/images/icons/panel/project_new.png" alt="icon" width="48px" height="48px" /><br />
					<?php echo $this->language['project_type_create'];?></span></a>
				</li>
			</ul>
		</div>
	</div>
	<div class="row">
		<div class="col-lg-12">
			<div class="panel">
				<div class="panel-heading">
					<div class="panel-title"><i class="icon-file-text-alt"></i> <?php echo $this->language['list'];?></div>
				</div>
				<div class="panel-body">
					<table class="table table-fixed table-hover table-condensed">
						<thead>
							<tr>
								<th>Loại dự án</th>
								<th width='50px'>&nbsp;</th>
							</tr>
						</thead>
						<tbody>
							<?php foreach($this->types as $row): ?>
							<tr>
								<td><?php echo $row['type_name'];?></td>
								<td>
									<a href='#group_create' rel="<?php echo $row['type_id'];?>" data-toggle="modal" class="type_group_create"><img src='resources/images/icons/plus.png' alt='Thêm nhóm' /></a>
									<a href='javascript:;' onClick="if(confirm('Are you Sure?')){deletePType(<?php echo $row['type_id'];?>);};" ><img src='resources/images/icons/cross.png' alt='Xóa loại dự án' /></a>
								</td>
							</tr>
							<?php foreach($row['type_groups'] as $group):?>
							<tr>
								<td>|---------- <?php echo $group['group_name']. " : " .$group['group_percent']." %";?></td>
								<td>
									<a href='javascript:;' onClick="if(confirm('Are you Sure?')){deleteTGroup(<?php echo $group['group_id'];?>);};" ><img src='resources/images/icons/cross.png' alt='Xóa nhóm' /></a>
								</td>
							</tr>
							<?php endforeach;?>
							<?php endforeach; ?>
						</tbody>
					</table>
				</div>
			</div>
		</div>
	</div>
	<div class="modal fade" id="type_create">
		<div class="modal-dialog">
			<div class="modal-content">
				<form action="javascript:createPType();">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
						<h4 class="modal-title">Tạo loại dự án mới</h4>
					</div>
					<div class="modal-body">
						<fieldset>
							<div class="form-group">
								<label for="noteTitle">Tên loại dự án</label>
								<input type="text" class="form-control" id="type_name" placeholder="Tên" />
							</div>
						</fieldset>
					</div>
					<div class="modal-footer">
						<input type="submit" class="btn btn-primary" value="Đồng ý" />
					</div>
				</form>
			</div>
		</div>
	</div>
	<div class="modal fade" id="group_create">
		<div class="modal-dialog">
			<div class="modal-content">
				<form action="javascript:createTGroup();">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
						<h4 class="modal-title">Tạo nhóm mới</h4>
					</div>
					<div class="modal-body">
						<fieldset>
							<div class="form-group">
								<label for="noteTitle">Tên nhóm</label>
								<input type="text" class="form-control" id="group_name" placeholder="Tên nhóm" />
							</div>
							<div class="form-group">
								<label for="noteTitle">Phần trăm</label>
								<input type="text" class="form-control" id="group_percent" placeholder="Phần trăm" />
							</div>
						</fieldset>
					</div>
					<div class="modal-footer">
						<input type="hidden" id="type_group_create" value="" />
						<input type="submit" class="btn btn-primary" value="Đồng ý" />
					</div>
				</form>
			</div>
		</div>
	</div>
	<script>
		$(document).ready(function() {
			$(".type_group_create").click(function(){
				var id = $(this).attr('rel');
				$("#type_group_create").val(id);
			});
		});
	</script>
<?php if(isset($this->breadcrumb) && isset($this->title_header)):?>
	<script type="text/javascript">
		$(function() {
			$("#title-header").text('<?php echo $this->title_header;?>');
			$("#breadcrumb").html('<?php echo build_breadcrumb($this->breadcrumb);?>');
		});
	</script>
<?php endif;?>
<?php
	if($_REQUEST['ajax']!=true) include 'footer.tpl.php';
?>